﻿if(ANDROID OR IOS)
  return()
endif()

file(GLOB_RECURSE X_ASSISTANT_SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/*.*)
list(APPEND X_ASSISTANT_SOURCES ${X_APPS_SOURCES})
list(APPEND X_ASSISTANT_SOURCES ${CMAKE_CURRENT_LIST_DIR}/xAssistant.rc)
list(APPEND X_ASSISTANT_SOURCES ${CMAKE_CURRENT_LIST_DIR}/xAssistant.qrc)
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)

set(bin ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_SYSTEM_NAME}/${CMAKE_BUILD_TYPE}/xAssistant)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${bin})
add_executable(xAssistant ${X_ASSISTANT_SOURCES})
x_tools_output_env(xAssistant)
x_tools_deploy_qt(xAssistant)
x_tools_deploy_qss(xAssistant)
target_link_libraries(xAssistant PRIVATE ${X_TOOLS_LIBS})
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
  set_target_properties(xAssistant PROPERTIES MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE)
else()
  option(X_ASSISTANT_TERMINAL "xAssistant with terminal" ON)
  if(X_ASSISTANT_TERMINAL)
    set_target_properties(xAssistant PROPERTIES MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE)
  else()
    # QDebug info will be printed to terminal(for vscode)
  endif()
endif()

# --------------------------------------------------------------------------------------------------
# Make installer for Windows
if(WIN32 AND X_TOOLS_LATEST_GIT_TAG)
  set(icon ${CMAKE_CURRENT_SOURCE_DIR}/xAssistant.ico)
  x_tools_generate_zip(xAssistant ${X_TOOLS_LATEST_GIT_TAG})
  x_tools_generate_msix(xAssistant "xAssistant" "xAssistant" ${X_TOOLS_LATEST_GIT_TAG} FALSE)
  x_tools_generate_installer(xAssistant ${X_TOOLS_LATEST_GIT_TAG} ${icon})
endif()
